<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
            1. 普通函数，谁调用它，this指向谁
            2. 箭头函数，this指向定义时的上下文
        */
      const obj = {
        name: 'obj',
        sayHello() {
          console.log('obj.sayHello -----> ', this);
        },
        sayHi: () => {
          console.log('箭头函数sayHi -----> ', this);
        },
      };

      obj.sayHello(); // this 指向 obj
      obj.sayHi(); // this 指向 window
    </script>
  </body>
</html>
